package com.mit.wx.wx.dto;

import com.mit.wx.util.xml.CDataConverter;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author 郭文梁
 * <p>Create by 郭文梁</p>
 * <p>FOR: </p>
 */
@EqualsAndHashCode(callSuper = true)
@Data
@XStreamAlias("xml")
public class TargetImageMessage extends TargetMessage {
    public TargetImageMessage() {
        this.setMsgType(WxMessages.TYPE_IMAGE);
    }

    @XStreamAlias("Image")
    private Image image;

    public void mediaId(String mediaId) {
        if (image == null) {
            image = new Image();
        }
        image.setMediaId(mediaId);
    }
}

@Data
class Image {
    @XStreamConverter(CDataConverter.class)
    @XStreamAlias("MediaId")
    private String mediaId;
}
